const koa = require("koa");
const router = require("koa-router")();
const render = require("koa-art-template");
const path = require("path");

const captcha = require("./routers/captcha");

const app = new koa();

render(app, {
  root: path.join(__dirname, "views"), //模板引擎文件夹
  extname: ".html", //模板后缀名
  debug: process.env.NODE_ENV !== "production", //是否开启报错调试提醒，默认基因型
});

router.get("/", async (ctx) => {
  await ctx.render("index");
});

router.use("/captcha", captcha.routes());

app.use(router.routes());

app.listen(666, () => {
  console.log("Server is running on port 666!");
});
